<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('附件列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:appendix:add">-->
                <a class="btn btn-success" onclick="tianjia()" shiro:hasPermission="system:appendix:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:appendix:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:appendix:remove')}]];
        var prefix = ctx + "system/appendix";
        var docId = '[[${docId}]]';
        var docType = '[[${docType}]]';
        $(function() {
            var options = {
                url: prefix + "/list/"+docId+"/"+docType,
                createUrl: prefix + "/add/"+docId+"/"+docType,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "附件",
                queryParams:{docId:docId,docType:docType},
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'appendixName',
                    title: '附件名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href= "'+ row.appendixLocation + '"  target="_blank"><i class="fa fa-edit"></i>预览</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function tianjia() {
            var url = prefix + "/add/"+docId+"/"+docType;
            var options = {
                title: table.options.modalName + "附件",
                width: 800,
                height: 550,
                url: url,
                skin: 'layui-layer-gray',
                btn: ['关闭'],
                yes: function (index, layero) {
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
            // $.modal.open("附件管理" + table.options.modalName, url)
        }
    </script>
</body>
</html>